package com.app.micaihu.configure;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;

import com.app.micaihu.R;
import com.app.micaihu.ad.AdConfig;
import com.app.micaihu.bean.news.NewsEntity;
import com.app.micaihu.view.main.MainActivity;
import com.app.micaihu.view.main.game.GameDetailActivity;
import com.app.micaihu.view.main.game.GameRaidersNewsActivity;
import com.app.micaihu.view.main.game.GameRaidersVideoActivity;
import com.app.micaihu.view.main.topic.PostDetailActivity;
import com.app.micaihu.view.newsdetail.ImageDetailActivity;
import com.app.micaihu.view.newsdetail.NewsDetailActivity;
import com.app.micaihu.view.newsdetail.NewsTopicsActivity;
import com.app.micaihu.view.newsdetail.VideoDetailActivity;
import com.app.micaihu.view.shop.CommodityDetailActivity;
import com.app.micaihu.view.shop.CommodityPicDetailActivity;
import com.app.micaihu.view.user.userinfo.activity.MyHomepageDynamicActivity;
import com.app.micaihu.view.user.userinfo.activity.WebActivity;
import com.blankj.utilcode.util.ActivityUtils;

/**
 * 一些类型常量
 * Created by linkai on 2016/7/17.
 */
public class TypeConstant {

    /***************** 通用的操作类型  *****************/

    public final static String HANDLER_TYPE_1 = "1";//操作类型1
//    public final static String HANDLER_TYPE_2 = "2";//操作类型2

    /***************** 新闻类型  *****************/
    // 文章类型(没有匹配的类型可能为广告类型 在广告系统中匹配了)
    public final static String NEWS_NORMAL = "1";//普通文章
    public final static String PIC_NORMAL = "2";//普通图集
    public final static String VIDEO_NORMAL = "3";//普通视频
    public final static String NEWS_SHOP = "15";//电商文章(不能评论) 原定为4 2.0.3版本改为 15
    public final static String NEWS_SHOP_WEB = "16";//电商网页文章(不能评论) 原定为6 2.0.3版本改为、                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             16
    public final static String NEWS_WEB = "17";//网页文章(能评论) 原定为5 2.0.3版本改为 17
    public final static String VIDEO_WEB = "7";//网页视频
    public final static String PIC_TOPIC = "8";//图集轻专题
    public final static String AD = "9";//广告(百度广告) ios中 13 为广点通类型 5 为自定义广告类型
    public final static String NEWS_TOPIC = "10";//新闻专题
    public final static String TOPIC_POST = "11";//话题
    public final static String VIDEO_ORIGINAL = "12";//原创视频
    public final static String AD_GDT = "13";//广点通广告
    public final static String PUSH_COMMENT = "14"; //推送的评论
    public final static String GAME_VIDEO = "18"; //可下载的游戏视频广告
    public final static String GAME_IMAGE = "19"; //可下载的游戏图片广告
    public final static String ONLY_URL = "20";//直接跳转webActivity的表示
    public final static String POST_2052 = "21";//新版 话题 跳转标示
    public final static String GAME_RAIDERS_TEXT = "24";//游戏图文攻略
    public final static String GAME_RAIDERS_VIDEO = "25";//游戏视频攻略
    public final static String SHOP_ALI = "26";//图文商品详情
    public final static String SHOP_ALI_PIC = "27";//图库商品详情
    public final static String GAME_RANKING = "28";//游戏排行榜
    public final static String NEWS_MARKET = "31";//电商
    public final static String EXCLUSIVE_NEWS_BIG_IMAGE = "32";//独家大图
    public final static String EXCLUSIVE_NEWS_VIDEO = "33";//独家视频
    //个人主页(因为服务器没有此类型,此类型这在客户端做逻辑判断,所以值偏大,不影响服务器的依次添加)
    public final static String PERSONAL_HOMEPAGE = "99";
    public final static String FLUSH = "100";//刷新


    /**
     * 匹配新闻类型
     *
     * @param articleType
     * @return
     */
    public static String getNewsTypeName(String articleType) {
        if (TextUtils.isEmpty(articleType)) {
            return "";
        }
        switch (articleType) {
            //适配所有文章
            case TypeConstant.NEWS_NORMAL:
            case TypeConstant.NEWS_WEB:
                return "文章";
            case TypeConstant.NEWS_SHOP:
            case TypeConstant.NEWS_SHOP_WEB:
                return "软文";
            //适配图库
            case TypeConstant.PIC_NORMAL:
                return "图集";
            //适配图库轻专题
//            case TypeConstant.PIC_TOPIC://暂时不做这个类型的适配
//                return "轻专题";
            //普通视频
//            case TypeConstant.VIDEO_WEB://暂时不做这个类型的适配
            case TypeConstant.VIDEO_NORMAL:
                return "视频";
            case TypeConstant.NEWS_TOPIC:
                return "新闻专题";
//            case TypeConstant.TOPIC_POST:
            case TypeConstant.POST_2052:
                return "话题";
            case TypeConstant.VIDEO_ORIGINAL:
                return "原创视频";
            case TypeConstant.AD:
                return "广告";
            case TypeConstant.GAME_VIDEO:
                return "游戏视频下载";
            case TypeConstant.GAME_RAIDERS_TEXT:
                return "游戏图文攻略";
            case TypeConstant.GAME_RAIDERS_VIDEO:
                return "游戏视频攻略";
            case TypeConstant.SHOP_ALI:
                return "图文商品";
            case TypeConstant.SHOP_ALI_PIC:
                return "图片商品";
            case TypeConstant.NEWS_MARKET:
                return "电商";

            default:
                return "";
        }
    }

    /**
     * 判断当前视频类型是否可播放
     *
     * @param newsEntity
     * @return
     */
    public static boolean getVideoIsPlay(NewsEntity newsEntity) {
        if (TextUtils.isEmpty(newsEntity.getUrlStatus())) {
            return false;
        }
        if (TextUtils.equals(newsEntity.getUrlStatus(), NEWS_VIDEO_TYPE1)
                || TextUtils.equals(newsEntity.getUrlStatus(), NEWS_VIDEO_TYPE2)
                || TextUtils.equals(newsEntity.getUrlStatus(), NEWS_VIDEO_TYPE3)) {
            if (!TextUtils.isEmpty(newsEntity.getVideoCurl())
                    || !TextUtils.isEmpty(newsEntity.getVideoUrl())) {
                return true;
            }
        }
        return false;
    }

    /**
     * 公用的跳转新闻方法
     *
     * @param newsEntity
     * @param activity
     */
    public static boolean openTypeDetail(NewsEntity newsEntity, Activity activity, String sourceType) {

        if (activity == null || newsEntity == null || TextUtils.isEmpty(newsEntity.getArticleType())) {
            return false;
        }
        Intent intent = new Intent();
        //适配文章类型
        switch (newsEntity.getArticleType()) {
            //适配所有文章
            case TypeConstant.NEWS_NORMAL:
            case TypeConstant.EXCLUSIVE_NEWS_BIG_IMAGE:
            case TypeConstant.NEWS_SHOP:
            case TypeConstant.NEWS_WEB:
                intent.setClass(activity, NewsDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, sourceType);
                ActivityUtils.startActivity(intent);
                break;
            case TypeConstant.NEWS_MARKET:
                intent.setClass(activity, NewsDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, sourceType);
                intent.putExtra(Config.Extra.isMarketAd, true);
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "新闻", 1);// 统计的点击的次数
                return true;
            case TypeConstant.NEWS_SHOP_WEB://电商网页文章
                intent.setClass(activity, WebActivity.class);
                intent.putExtra("url", newsEntity.getJumpUrl());
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "电商软文", 1);// 统计的点击的次数
                break;
            //适配图库
            case TypeConstant.PIC_NORMAL:
                intent.setClass(activity, ImageDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "图库", 1);// 统计的点击的次数
                return true;
            //适配图库轻专题
            case TypeConstant.PIC_TOPIC:
                //待开发
                return true;
            //适配新闻专题
            case TypeConstant.NEWS_TOPIC:
                intent.setClass(activity, NewsTopicsActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "新闻专题", 1);// 统计的点击的次数
                return true;
            //视频
            case TypeConstant.VIDEO_ORIGINAL:
            case TypeConstant.VIDEO_NORMAL:
            case TypeConstant.EXCLUSIVE_NEWS_VIDEO:
                intent.setClass(activity, VideoDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, sourceType);
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "视频", 1);// 统计的点击的次数
                return true;
            //话题
//            case TypeConstant.TOPIC_POST:
//                intent.setClass(activity, TopicDetailActivity.class);
//                intent.putExtra(BaseActivity.PARAMETER1, newsEntity.getArticleId());
//                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "话题", 1);// 统计的点击的次数
//                return true;

            case TypeConstant.POST_2052:
                intent.setClass(activity, PostDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
                return true;

            //自定义广告
            case TypeConstant.AD:
                if (newsEntity.getNativeAd() != null
                        && TextUtils.equals(newsEntity.getNativeAd().getAdType(), AdConfig.AD_TYPE_H5)) {
                    //如果是自定义的H5广告
                    intent.setClass(activity, WebActivity.class);
                    intent.putExtra("url", newsEntity.getNativeAd().getJumpUrl());
                    activity.startActivity(intent);
                    AdConfig.staticsAd(newsEntity.getSerialId(), AdConfig.TYPE_1, AdConfig.AD_TYPE_H5);
                }
//                StatService.onEvent(activity, "055", "广告", 1);// 统计的点击的次数
                return true;
            case TypeConstant.PUSH_COMMENT://推送的评论
                intent.setClass(activity, MainActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, newsEntity.getArticleType());
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "评论点击", 1);// 统计的点击的次数
                return true;

            case TypeConstant.GAME_VIDEO://游戏视频
                intent.setClass(activity, GameDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, TypeConstant.SOURCETYPE_NORMAL);
                intent.putExtra("serialId", newsEntity.getSerialId());
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "游戏视频点击跳转内页", 1);// 统计的点击的次数
                return true;
            case TypeConstant.GAME_RAIDERS_TEXT://游戏攻略
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, newsEntity.getGameId());
                intent.setClass(activity, GameRaidersNewsActivity.class);
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "游戏图文攻略点击", 1);// 统计的点击的次数
                return true;
            case TypeConstant.GAME_RAIDERS_VIDEO://游戏攻略
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                intent.putExtra(Config.Extra.PARAMETER2, newsEntity.getGameId());
                intent.setClass(activity, GameRaidersVideoActivity.class);
                activity.startActivity(intent);
//                StatService.onEvent(activity, "055", "游戏图文攻略点击", 1);// 统计的点击的次数
                return true;
            case TypeConstant.PERSONAL_HOMEPAGE://个人主页
                intent.setClass(activity, MyHomepageDynamicActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
                return true;
            case TypeConstant.ONLY_URL://推送网页
                intent.setClass(activity, WebActivity.class);
                intent.putExtra("url", newsEntity.getJumpUrl());
                activity.startActivity(intent);
                return true;
            case TypeConstant.SHOP_ALI://图文 商品详情
                intent.setClass(activity, CommodityDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
                return true;
            case TypeConstant.SHOP_ALI_PIC://图片商品详情
                intent.setClass(activity, CommodityPicDetailActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, newsEntity.getArticleId());
                activity.startActivity(intent);
                return true;
        }
        return false;
    }

    /***************** 新闻文章类型的UI类型  *****************/
    public final static String NEWS_UI_SMALL_IMG = "0";//小图
    public final static String NEWS_UI_BIG_ONE_IMG = "1";//大图样式一(新闻列表的图库样式)
    public final static String NEWS_UI_BIG_TWO_IMG = "2";//大图样式二(图库列表的样式)

    public final static String NEWS_ATTR_TOP = "1";//置顶
    public final static String NEWS_ATTR_HOT = "2";//热门
    public final static String NEWS_ATTR_RECOMMEND = "3";//推荐
    public final static String NEWS_ATTR_FIRST = "4";//首发
    public final static String NEWS_ATTR_EXCLUSIVE = "5";//独家
    public final static String NEWS_ATTR_VIP = "6";//VIP
    public final static String NEWS_ATTR_ORIGINAL = "7";//原创

    //用于栏目适配用
    public final static String CHANNEL_TYPE_NEWS = "1";//文章栏目类型
    public final static String CHANNEL_TYPE_PICS = "2";//图集栏目类型
    public final static String CHANNEL_TYPE_VIDEO = "3";//视频栏目类型


    /***************** 新闻文章的属性类型  *****************/

    //视频链接分类 1：外链视频 2：云视频 3：两者都有
    public final static String NEWS_VIDEO_TYPE1 = "1";
    public final static String NEWS_VIDEO_TYPE2 = "2";
    public final static String NEWS_VIDEO_TYPE3 = "3";//优先放云视频

    /************** 新闻视频类型 ************/

    /************** 新闻视频类型 ************/

    /******************** 文章来源类型 ********************/
    //来源类型 1正常列表 2相关列表 3网页 4push    5小编推荐
    public final static String SOURCETYPE_NORMAL = "1";
    public final static String SOURCETYPE_ABOUT = "2";
    public final static String SOURCETYPE_WEB = "3";
    public final static String SOURCETYPE_PUSH = "4";
    public final static String SOURCETYPE_RECOMMEND = "5";//小编推荐 中进入的
    public final static String SOURCETYPE_FOCUS = "6";//要闻推送进入的
    public final static String SOURCETYPE_SYSMSG = "7";//系统消息

    /******************** 文章来源类型 ********************/

    /**************** 评论类型 ******************/
    public final static String COMMENT_PARENT = "0";//对文章的评论
    public final static String COMMENT_ONE = "1";//一级评论
    public final static String COMMENT_TWO = "2";//二级评论
    /**************** 评论类型 ******************/

    /***************** 登录类型 *****************/
    public final static String WEIXIN_LOGIN = "1";
    public final static String QQ_LOGIN = "2";
    public final static String PHONE_LOGIN = "3";
    public final static String SINA_LOGIN = "4";
    /***************** 登录类型 *****************/
    public final static String PLATFORM = "1";//手机平台 1:android
    /*****************验证码类型 *****************/
    public final static String REGISTER_CODE = "0";//手机注册
    public final static String FINDPWD_CODE = "1";//忘记密码
    public final static String BINDPHONE_CODE = "2";//绑定手机
    public final static String CHANGEPHONE_CODE = "3";//更改手机
    public final static String RESETPWD_CODE = "4";//修改密码
    public final static String LOGIN_CODE = "5";//登录

    /***************** 操作类型 *****************/
    //操作类型的name
    public final static String ACTION_TYPE = "action_type";

    //操作类型的value
    public final static String CHANGEPHONE_ACTION = "change";//修改手机
    public final static String REGISTER_ACTION = "register";//注册
    public final static String BINDPHONE_ACTION = "bindphone";//绑定手机
    public final static String RESETPWD_ACTION = "resetpwd";//修改密码
    public final static String FINDPWD_ACTION = "findpwd";//修改密码

    /***************** 操作类型 *****************/


    /***************** 验证手机号类型 *****************/
    public final static String CHANGE_PWD = "1";//找回密码
    public final static String CHANGE_PHONE = "2";//更改手机号
    public final static String BIND_PHONE = "3";//绑定手机号;注册手机号
    public final static String CHANGE_PWD2 = "4";//修改密码


    /***************** 修改密码类型 *****************/
    public final static String CHANGE_PWD_TYPE1 = "1";//修改密码
    public final static String CHANGE_PWD_TYPE2 = "2";//忘记密码

    /***************** 推送类型 *****************/
    public final static String PUSH_TYPE = "push_type";//推送的name

    public final static String PUSHTYPE_XIAOMI = "1";//小米推送的value
    public final static String PUSHTYPE_UMENG = "2";//友盟推送的value

    /***************** 推送类型 *****************/

    /**************上传图片类型 ****************/
    public final static String UPLOAD_TYPE1 = "1";//上传头像
    public final static String UPLOAD_TYPE2 = "2";//话题发帖


    /**************话题中帖子类型****************/
    public final static String NORMAL_POST = "1";//正常帖子

    /**************发表帖子是否允许发图****************/
    public final static String TANS_IMG = "1";//允许发图


    public final static String SHARE_TYPE_NEWS = "1";//文章类型
    public final static String SHARE_TYPE_TOPIC = "2";//话题类型
    public final static String SHARE_TYPE_VIDEO = "3";//视频类型
    public final static String SHARE_TYPE_POST = "4";//帖子类型


    /**************消息中心类型****************/
    //消息分类 1评论 2@我 3消息提醒 4粉丝 5虎妞客服 6点赞 9 军团消息
    public final static String MSG_COMMENT = "1";
    public final static String MSG_AT = "2";
    public final static String MSG_NOTICE = "3";
    public final static String MSG_FANS = "4";
    public final static String MSG_FEEDBACK = "5";
    public final static String MSG_ZAN = "6";
    public final static String MSG_RECOMMEND = "7";
    public final static String MSG_SHOP = "8";
    public final static String MSG_ARMY = "9";

    //系统消息的类型
    public final static String MSG_NOTICE_USER = "1";//用户
    public final static String MSG_NOTICE_NEWS = "2";//文章/话题
    public final static String MSG_NOTICE_REASON = "3";//原因


    /**************EmptyView---图片****************/

    public final static int EMPTYVIEW_PEN = R.drawable.empty_icon_com;
    public final static int EMPTYVIEW_CLOCK = R.drawable.empty_icon_comment;
    public final static int EMPTYVIEW_DEFAULT = R.drawable.empty_icon_news;
    public final static int EMPTYVIEW_BANSPEECH = R.drawable.user_per_homepage_banspeech;


    /**************作战中心领取奖励的类型****************/
    public final static String CAN_NOT_REWARD = "0";
    public final static String CAN_REWARD = "1";
    public final static String REWARDED = "2";


    /**************推送类型****************/
    public final static String PUSH_FOCUSNEWS = "1";//要闻-弹dialog-不弹通知栏
    public final static String PUSH_NORMAL = "0";//普通推送——弹出通知栏


    /**************页面类型****************/
    public final static String PAGE_NEWS = "1";//新闻类型
    public final static String PAGE_COMMENT = "2";//评论类型----一级评论类型
    public final static String PAGE_POST = "3";//话题类型-别人的帖子
    public final static String PAGE_MINE_POST = "4";//自己的帖子
    public final static String PAGE_VIDEO_ORIGINAL = "5";//原创房间页面
    public final static String PAGE_TOPIC_DETAIL = "6";//话题页面
    public final static String PAGE_VIDEO_DETAIL = "7";//视频详情页面
    public final static String PAGE_HOME = "8";//个人主页--举报用
    public final static String PAGE_OTHER_HOME = "9";//别人的个人主页
    public final static String PAGE_COMMENT_CHILD = "10";//评论类型----非一级评论类型
    public final static String PAGE_POST_COMMENT_CHILD = "11";//帖子类型-----非一级的帖子类型
    public final static String PAGE_NEWS_DETAIL = "12";//正文新闻详情页面类型
    public final static String PAGE_NEWS_DETAIL1 = "13";//正文新闻详情右上角页面类型
    public final static String PAGE_AUTHOR_PAGE = "14";//作者主页
    public final static String PAGE_GAME_DETAIL = "15";//游戏详情


    public final static String ONLY_SHARE = "0";//只有分享


    /**************关注类型****************/
    public final static String ATTENTION_NO = "0";//未关注
    public final static String ATTENTION_YES = "1";//已关注
    public final static String ATTENTION_ALL = "2";//互相关注


    /**************删除类型****************/
    public final static String ONE_LEVEL = "0";//一级评论：对文章和话题的的操作
    public final static String TWO_LEVEL = "1";//二级评论：对评论和留言的评论；


    /**************zan类型****************/
    public final static String ZAN_NORMAL = "0";//帮上头条
    public final static String ZAN_CANCLE = "1";//取消赞
    public final static String ZAN_DISLIKE = "2";//不喜欢


    /**************举报类型****************/
    public final static String JUBAO_NEWS = "1";
    public final static String JUBAO_COMMENT_PARENT = "2";
    public final static String JUBAO_POST = "3";
    public final static String JUBAO_COMMENT_CHILD = "4";
    public final static String JUBAO_POST_CHILD = "5";
    public final static String JUBAO_USER = "6";


    /**************唤醒类型****************/
    public final static String WAKE_UP_MICAIHU_APP = "0";//单纯打开app
    public final static String WAKE_UP_NEWS = "1";//新闻详情
    public final static String WAKE_UP_VIDEO = "2";//视频
    public final static String WAKE_UP_TOPIC = "3";//话题
    public final static String WAKE_UP_ORIGNAL = "4";//原创
    public final static String WAKE_UP_PIC = "5";//图库
    public final static String WAKE_UP_SPECIAL = "6";//专题
    public final static String WAKE_UP_USERHOME = "7";//个人主页
    public final static String WAKE_UP_GAME = "8";//游戏唤醒
    public final static String WAKE_UP_GAME_TXT = "9";//游戏图文攻略唤醒
    public final static String WAKE_UP_GAME_VIDEO = "10";//游戏视频图文唤醒


    /****************操作类型****************/
    public final static String CONFIRM_OPRATION = "1";
    public final static String CANCLE_OPRATION = "2";


}
